package lk;

public class D230913 {
    // 交替合并字符串
    public String mergeAlternately(String word1, String word2) {
        int length1 = word1.length();
        int length2 = word2.length();
        StringBuilder sb = new StringBuilder();
        int i = 0;
        for (; i < length1 && i < length2; i++) {
            sb.append(word1.charAt(i));
            sb.append(word2.charAt(i));
        }
        if (i < length1) {
            sb.append(word1.substring(i));
        }
        if (i < length2) {
            sb.append(word2.substring(i));
        }
        return sb.toString();
    }
}
